package sunlight.util;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import sunlight.core.Application;
import sunlight.logger.EventLogger;

public class WindowReporter {
	
	public JFrame Wrapper;
	
	public WindowReporter(JFrame wrapper){
		this.Wrapper = wrapper;
	}
	
	public void showAlert(String title, String message, boolean logThis, String logMessage){
		JOptionPane.showMessageDialog(this.Wrapper, message, title, JOptionPane.WARNING_MESSAGE);
		
		if(logThis){
			this.logIt(logMessage, EventLogger.WARNING);
		}
	}
	
	public void showAlert(String title, String message){
		this.showAlert(title, message, false, null);
	}
	
	public void showMessage(String title, String message, boolean logThis, String logMessage){
		JOptionPane.showMessageDialog(this.Wrapper, message, title, JOptionPane.PLAIN_MESSAGE);
		
		if(logThis){
			this.logIt(logMessage, EventLogger.MESSAGE);
		}
	}
	
	public void showMessage(String title, String message){
		this.showMessage(title, message, false, null);
	}
	
	public void showInfo(String title, String message, boolean logThis, String logMessage){
		JOptionPane.showMessageDialog(this.Wrapper, message, title, JOptionPane.INFORMATION_MESSAGE);
		
		if(logThis){
			this.logIt(logMessage, EventLogger.MESSAGE);
		}
	}
	
	public void showInfo(String title, String message){
		this.showInfo(title, message, false, null);
	}
	
	public void showError(String title, String message, boolean logThis, String logMessage){
		JOptionPane.showMessageDialog(this.Wrapper, message, title, JOptionPane.ERROR_MESSAGE);
		
		if(logThis){
			this.logIt(logMessage, EventLogger.ERROR);
		}
	}
	
	public void showError(String title, String message){
		this.showError(title, message, false, null);
	}
	
	public void logIt(String message, String type){
		Application.Log.write(message, type);
	}
}
